package com.transcasafe.eanpay.core.cipher;

import com.transcasafe.eanpay.core.util.ShaUtil;

import java.nio.charset.StandardCharsets;

/**
 * SHA256签名器
 */
public final class SHA256Signer implements Signer {


    private final String mchKey;

    public SHA256Signer(String mchKey) {
        this.mchKey = mchKey;
    }

    @Override
    public SignatureResult sign(String message) {
        return new SignatureResult(ShaUtil.getSha256HexString((message + "," + mchKey).getBytes(StandardCharsets.UTF_8)));
    }
}
